package hn.cch.spring.core.annotation;

import hn.cch.spring.core.annotation.component.ComponentConfiguration;
import hn.cch.spring.core.annotation.processor.BeanAnnotationPostProcessor;
import hn.cch.spring.core.annotation.processor.ComponentScanPostProcessor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.support.GenericApplicationContext;

public class AnnotationDemo {
    private static final Logger logger = LoggerFactory.getLogger(AnnotationDemo.class);

    public static void main(String[] args) {
        // 注解实现过程
        GenericApplicationContext applicationContext = new GenericApplicationContext();
        applicationContext.registerBean("componentConfiguration", ComponentConfiguration.class);
        // applicationContext.registerBean(ConfigurationClassPostProcessor.class);// @ComponentScan @Bean @Import @ImportResource

        // 实现过程
        applicationContext.registerBean(ComponentScanPostProcessor.class); // @ComponentScan
        applicationContext.registerBean(BeanAnnotationPostProcessor.class); // @Bean

        applicationContext.refresh();

        for (String name : applicationContext.getBeanDefinitionNames()) {
            logger.info(name);
        }
        applicationContext.close();
    }
}
